import type { App, DirectiveBinding } from 'vue'
import useUserStore from '@/store/modules/user'

export function isHasButton(app: App) {
  const userStore = useUserStore()

  app.directive('hasButton', {
    mounted(el: HTMLElement, binding: DirectiveBinding) {
      if (!userStore.buttons.includes(binding.value)) {
        el.style.display = 'none' // 隐藏元素，而不是直接删除
      }
    },
  })
}
